package cn.hxzy.erweima.service;

import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

@Service
public class QRService {
    @Autowired
    private QrConfig qrConfig;
    public void generateFile(String content, File file){
        //生成到本地文件
        QrCodeUtil.generate(content,qrConfig,file);
    }
    public void generateStream(String content, HttpServletResponse response) throws IOException {
        //输出到流
        QrCodeUtil.generate(content,qrConfig,"png",response.getOutputStream());
    }

}
